// login里的表单验证
export const loginRules = {

  mobile: [{

    required: true,
    pattern: /^1[3|4|5|7|8][0-9]{9}$/,
    message: '手机号不正确',
    trigger: 'blur' // 在失去焦点触发验证规则
  }],
  code: [
    { min: 6, max: 6, required: true, message: '验证码6位', trigger: 'change' }
  ],
  check: [
    {
      required: true,
      trigger: 'change',
      validator: (rule, value, callback) => {
        if (value) callback() // 如果选中了就正确继续-callback()什么都不传就代表正确
        else callback(new Error('请勾选协议'))
      }
    }
  ]

}
// article.vue里的表单验证
export const articleRules = {

  title: [ // 规则名(必须和v-model的变量名一致)
    {
      min: 5,
      max: 30,
      required: true,
      message: '标题5到30字符',
      trigger: 'blur' // 在失去焦点触发验证规则
    }
  ],
  content: [
    { required: true, message: '内容必须填写', trigger: 'blur' }
  ],
  channel_id: [
    {
      required: true,
      trigger: 'blur',
      message: '频道必须选择'
    }
  ]

}
